<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8"> 
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title> 
</head>
<body>
    <div>
        <input type="button" value="0"> 
    </div>
</body>
<script>
    //获取inout框
    var input=document.querySelector("input")
    console.log(input) 
    //定义一个函数
    function sum(){
        //parseInt将字符转为数字
         var sum=parseInt(input.value)
         var i=1   
         return (sum+=i) 
    }
    //点击input框的时候弹出sum
    input.onclick=function(){
         alert ( sum())
         this.value=sum()
    }
</script>
</html>
<style>
    div{
        text-align: center;
    }
</style>